package ZiXi;

import java.util.ArrayList;

public class TestSinger {
    public static void main(String[] args) {
        // 2. 创建集合对象
        ArrayList<Singer> list = new ArrayList<>();
        // 3. 创建歌手对象
        Singer stu1 = new Singer("刘德华",25,"打篮球");
        Singer stu2 = new Singer("张学友",35,"游泳");
        Singer stu3 = new Singer("郭富城",19,"踢足球");
        Singer stu4 = new Singer("黎明",20,"击剑");
        // 4. 添加歌手对象到集合中
        list.add(stu1);
        list.add(stu2);
        list.add(stu3);
        list.add(stu4);
        // 5. 遍历集合，采用通用遍历格式实现
        for (int i = 0; i < list.size(); i++) {
            Singer stu = list.get(i);
            if(stu.getAge()>30){
                stu.setLike("打保龄球");
                System.out.println(stu.getName() + "..." + stu.getAge()+"..."+stu.getLike());
            }else if(stu.getAge()<20){
                list.remove(stu);
            }else {System.out.println(stu.getName() + "..." + stu.getAge()+"..."+stu.getLike());
            }

        }
    }
}
